package com.bdmc.smokesensor.dao;
 
//import java.awt.print.Pageable;
import java.io.Serializable;
import java.util.List;
import java.util.Map;

import com.bdmc.smokesensor.entity.Smk_GroupCompany;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Query;
 
public interface Smk_GroupCompanyJPA extends JpaRepository<Smk_GroupCompany,Integer>,JpaSpecificationExecutor<Smk_GroupCompany>,Serializable {
  
    @Query(value="SELECT new map(g.id as id,g.groupName as groupName,d.city as city, d.depName as depName,g.addr as addr,g.managerName as managerName, "+
    "g.managerMobile as managerMobile,g.officeMobile as officeMobile,g.smkAreasId as smkAreasId,DATE_FORMAT(g.joinDate,'%Y-%m-%d %H:%i:%S') as joinDate, "+
    " g.smkMaintenanceId as smkMaintenanceId,g.departmentId as  departmentId) "+
    "from Smk_GroupCompany g  INNER JOIN Sys_Department d on g.departmentId=d.id "+
    " where (d.id=:depId or d.treeRoot LIKE %:treeRoot%) and g.groupName like %:groupName%")
    public Page<Map<String,Object>> getCurrentGroupCompany(int depId,String treeRoot,String groupName,Pageable pageable);

    public Long countByDepartmentId(int dep_id);
}
